package com.xcf.controller.business.common;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.xcf.controller.base.BaseController;
import com.xcf.entity.Page;
import com.xcf.service.business.common.exportcountrymanagement.ExportCountryManagementService;
import com.xcf.util.PageData;

@Controller
@RequestMapping(value = "/export")
public class ExportCountryManagementController extends BaseController {
	@Resource
	private ExportCountryManagementService exportcountrymanagementservice;
	String menuUrl = "export/management";// 菜单地址(权限用)

	@RequestMapping(value = "/management")
	// 列表的查询及显示
	public ModelAndView export(Page page) {
		ModelAndView mv = this.getModelAndView();
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			String ENGLISH_NAME = pd.getString("ENGLISH_NAME"); // 判断英文名
			if (null != ENGLISH_NAME && !"".equals(ENGLISH_NAME)) {
				pd.put("ENGLISH_NAME", ENGLISH_NAME.trim());
			}
			String CHINESE_NAME = pd.getString("PORT_CHINESE_NAME"); // 判断中文名
			if (null != CHINESE_NAME && !"".equals(CHINESE_NAME)) {
				pd.put("CHINESE_NAME", CHINESE_NAME.trim());
			}
			String FAST_SEARCH_CODE = pd.getString("FAST_SEARCH_CODE"); // 判断检索码
			if (null != FAST_SEARCH_CODE && !"".equals(FAST_SEARCH_CODE)) {
				pd.put("FAST_SEARCH_CODE", FAST_SEARCH_CODE.trim());
			}
			String EXPORT_COUNTRY_CODE = pd.getString("EXPORT_COUNTRY_CODE"); // 判断出口国代码
			if (null != EXPORT_COUNTRY_CODE && !"".equals(EXPORT_COUNTRY_CODE)) {
				pd.put("EXPORT_COUNTRY_CODE", EXPORT_COUNTRY_CODE.trim());
			}
			page.setPd(pd);

			List<PageData> list = exportcountrymanagementservice.seach(page);
			mv.addObject("list", list);
			mv.addObject("pd", pd);
			mv.setViewName("/business/common/exportcountrymanagement/exportcountrymanagement");
		} catch (Exception e) {

			e.printStackTrace();
		}

		return mv;

	}

	// 点添加新增一条
	@RequestMapping(value = "/addaexport")
	@ResponseBody
	public String addship() {
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			if (pd.getString("ID") == null || pd.getString("ID") == "") {
				exportcountrymanagementservice.addexport(pd);
			} else {
				exportcountrymanagementservice.updateexport(pd);
			}

		} catch (Exception e) {

			e.printStackTrace();
		}
		return null;

	}

	// 修改页面
	@RequestMapping(value = "/editexport")
	public ModelAndView shipedit() {
		ModelAndView mv = this.getModelAndView();
		try {
			PageData pd = new PageData();
			pd = this.getPageData();
			pd = exportcountrymanagementservice.seacById(pd);
			mv.addObject("pd", pd);
			mv.setViewName("/business/common/exportcountrymanagement/exportcountrymanagement_edit");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mv;
	}

	// 删除
	@RequestMapping(value = "deleteexport")
	@ResponseBody
	public String deleteU() {
		PageData pd = new PageData();
		pd = this.getPageData();
		try {
			exportcountrymanagementservice.delete(pd);

		} catch (Exception e) {

			e.printStackTrace();
		}
		return null;

	}

}
